package demo1;

class Node<T>{
    T data;

    public void setData(T data){
        this.data = data;
    }

}

class Person{

}

class Student extends Person{

}

class StringNode extends Node<String>{
    @Override
    public void setData(String data) {
        super.setData(data);
    }
}

class MyArray1<E extends Number>{

}

class MyArray2<E extends Person>{

}

public class Test {

    public static int missingNumber(int[] nums) {
        int sum = 0;
        for (int i = 0; i <= nums.length; i++) {
            sum += i;
        }

        for (int i = 0; i < nums.length; i++) {
            sum -= nums[i];
        }

        return sum;
    }

    public static void main(String[] args) {
        MyArray1<Integer> myArray1 = new MyArray1<>();
        MyArray2<Student> myArray2 = new MyArray2<>();
        MyArray2<Person> myArray3 = new MyArray2<>();
    }

    public static void main5(String[] args) {
        Node<String> node = new StringNode();
        node.setData("hello");
    }

    public static void main4(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setVal(0, 10);
        myArray.setVal(1, 12);
        int ret = myArray.getPos(1);
        System.out.println(ret);

        // myArray.setVal(2, "bit");
    }

    public static void main3(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setVal(0, 1);
        myArray.setVal(1, "123"); // 字符串也能存放

        String ret = (String) myArray.getPos(1);
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        int i = 10;
        // 装箱
        Integer ii = Integer.valueOf(i);
        // Integer ij = new Integer(i);

        // 拆箱
        int j = ii.intValue();
        System.out.println(ii);
        System.out.println(j);

        // 自动装箱
        Integer iii = i;

        // 自动拆箱
        int jj = iii;

        System.out.println(iii);
        System.out.println(jj);

        Integer a = 127;
        Integer b = 127;

        Integer c = 128;
        Integer d = 128;

        System.out.println(a == b);
        System.out.println(c == d);

    }

    public static void main1(String[] args) {
        int[] array = {9,8,7,5,4,3,2,1,0};
        int ret = missingNumber(array);
        System.out.println(ret);
    }
}
